package com.cjm.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by tony on 2015/6/26.
 */
@Controller
public class TestRequestMapping {

    @RequestMapping(value = "/testPathVariable/{id}")
    public String testPathVariable(@PathVariable(value = "id") Integer id){
        System.out.println("testPathVariable： "+ id);
        return "success";
    }

    @RequestMapping(value = "/testAntPath/*/mvc")
    public String testAntPath() {
        return "success";
    }

    /**
     * 1.使用@RequestMapping 注解来映射请求的URL
     * 2.使用在springmvc.xml文件中配置好的视图解析器来将返回值解析为实际的物理视图，，对于InternalResourceViewResolver
     * 视图解析器，会进行这样的解析，prefix（路径名）+returnVal(返回值)+suffix（后缀名）,得到实际的物理视图，然后进行转发操作
     * 对于本springmvc来说，获得的实际视图为/WEB-INF/views/success.jsp
     * 3.@RequestMapping除了修改方法，还可以修饰类
     *
     * @return
     */
/*
    使用method进行指定请求方法的类型
*/
    @RequestMapping(value = "/testRequestMapping", method = RequestMethod.POST, params = {"username", "age !=10"})
    public String testRequestMapping() {
        System.out.println("requestMapping");
        return "success";
    }
}
